package com.ecoolex.union.pay.retailer.core.manager;

import com.ecoolex.union.pay.retailer.core.dao.UnionPayCouponVerifyingConsumptionDAO;
import com.ecoolex.union.pay.retailer.entity.UnionPayCoupon;
import com.ecoolex.union.pay.retailer.entity.UnionPayCouponVerifyingConsumption;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.Instant;
import java.util.Date;

@Service
public class UnionPayCouponVerifyingConsumptionManager {
    @Autowired
    private UnionPayCouponVerifyingConsumptionDAO dao;

    public void create(UnionPayCoupon coupon, String orderNo, BigDecimal realAmt, String createUser) {
        UnionPayCouponVerifyingConsumption record = new UnionPayCouponVerifyingConsumption();
        record.setCouponId(coupon.getCouponId());
        record.setUserId(coupon.getUserId());
        record.setOrderNo(orderNo);
        record.setRealPrice(realAmt);
        record.setDeleted(UnionPayCouponVerifyingConsumption.NOT_DELETED);
        record.setCreateUser(createUser);
        record.setCreateTime(Date.from(Instant.now()));
        record.setUpdateUser(createUser);
        record.setUpdateTime(Date.from(Instant.now()));
        dao.insert(record);
    }
}